﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Windows.Forms;
namespace Work2
{
    public partial class FrmSearchFather : Form
    {
        int flag = 0;
        public System.Windows.Forms.TextBox txt;
        public FrmSearchFather(System.Windows.Forms.TextBox txt)
        {
            this.txt = txt;
            InitializeComponent();
        }
        DataSet ds = new DataSet();
        DataView dv = null;
        private void FrmNewSearch_Load(object sender, EventArgs e)
        {
            string conStr = @"Data Source=LAPTOP-LER1MVBI\SQLEXPRESS;Initial Catalog=电子族谱系统;uid=sa;pwd=zxcvbnm123";
            SqlConnection conn = new SqlConnection(conStr);
            string assetName = txt.Text.Trim();
            if (assetName.Equals(""))
            {
                flag = 1;
                MessageBox.Show("暂无相关数据");
            }
            else
            {
                string sql = "select  Ufather_id,Ufather_name,Ufather_birth,Umate_name,Uchild_name from Ufather,Umate,Uchild  where  Uchild.[User]=Ufather.[User] and Umate.[User]=Ufather.[User] ";
                SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
                adapter.Fill(ds, "电子族谱系统");
                dv = ds.Tables["电子族谱系统"].DefaultView;
                dgvAsset1.DataSource = dv;
                dv.RowFilter = string.Format("Uchild_name like '%{0}%'", assetName);
            }
            if (dgvAsset1.Rows.Count == 0)
            {
                MessageBox.Show("暂无相关数据");
            }

        }

        private void DgvAsset1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
